'use strict';

exports.__esModule = true;
exports.modalHide = exports.modal = exports.errorAlertHide = exports.errorAlert = exports.errorModalHide = exports.errorModal = exports.MODAL_HIDE = exports.MODAL_SHOW = exports.ERROR_ALERT_HIDE = exports.ERROR_ALERT_SHOW = exports.ERROR_MODAL_HIDE = exports.ERROR_MODAL_SHOW = undefined;

var _handleActions, _handleActions2, _handleActions3;

var _redux = require('redux');

var _handleActions4 = require('../libs/handleActions');

var _handleActions5 = _interopRequireDefault(_handleActions4);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// ------------------------------------
// Constants
// ------------------------------------

var ERROR_MODAL_SHOW = exports.ERROR_MODAL_SHOW = 'ERROR_MODAL_SHOW';
var ERROR_MODAL_HIDE = exports.ERROR_MODAL_HIDE = 'ERROR_MODAL_HIDE';

var ERROR_ALERT_SHOW = exports.ERROR_ALERT_SHOW = 'ERROR_ALERT_SHOW';
var ERROR_ALERT_HIDE = exports.ERROR_ALERT_HIDE = 'ERROR_ALERT_HIDE';

var MODAL_SHOW = exports.MODAL_SHOW = 'MODAL_SHOW';
var MODAL_HIDE = exports.MODAL_HIDE = 'MODAL_HIDE';

// ------------------------------------
// Actions
// ------------------------------------

// show/hide error modal
var errorModal = exports.errorModal = function errorModal(payload) {
  return {
    type: ERROR_MODAL_SHOW,
    payload: payload
  };
};

var errorModalHide = exports.errorModalHide = function errorModalHide() {
  return {
    type: ERROR_MODAL_HIDE
  };
};

// show/hide error errorAlert
var errorAlert = exports.errorAlert = function errorAlert(payload) {
  return {
    type: ERROR_ALERT_SHOW,
    payload: payload
  };
};

var errorAlertHide = exports.errorAlertHide = function errorAlertHide() {
  return {
    type: ERROR_ALERT_HIDE
  };
};

// show/hide modal
var modal = exports.modal = function modal(view, data) {
  return {
    type: MODAL_SHOW,
    payload: { view: view, data: data }
  };
};

var modalHide = exports.modalHide = function modalHide() {
  return {
    type: MODAL_HIDE
  };
};

// ------------------------------------
// Reducers
// ------------------------------------

var errorModalReducer = (0, _handleActions5.default)((_handleActions = {}, _handleActions[ERROR_MODAL_SHOW] = function (state, _ref) {
  var payload = _ref.payload;
  return payload;
}, _handleActions[ERROR_MODAL_HIDE] = function () {
  return false;
}, _handleActions), false);

var errorAlertReducer = (0, _handleActions5.default)((_handleActions2 = {}, _handleActions2[ERROR_ALERT_SHOW] = function (state, _ref2) {
  var payload = _ref2.payload;
  return payload;
}, _handleActions2[ERROR_ALERT_HIDE] = function () {
  return false;
}, _handleActions2), false);

var modalReducer = (0, _handleActions5.default)((_handleActions3 = {}, _handleActions3[MODAL_SHOW] = function (state, _ref3) {
  var payload = _ref3.payload;
  return payload;
}, _handleActions3[MODAL_HIDE] = function () {
  return false;
}, _handleActions3), false);

exports.default = (0, _redux.combineReducers)({
  errorModal: errorModalReducer,
  errorAlert: errorAlertReducer,
  modal: modalReducer
});